package com.weirong.smartvault.common.tools.conf;

import com.weirong.smartvault.common.tools.model.EquipmentConfModel;
import jodd.props.Props;
import lombok.extern.slf4j.Slf4j;

import java.io.File;
import java.io.IOException;

@Slf4j
public class EquipmentConf {

    private static Props PROPS;

    private static EquipmentConfModel equipmentConfModel;

    private static void init()
    {
        if(PROPS == null)
        {
            try {
                PROPS = new Props();
                PROPS.load(new File(EquipmentConf.class.getResource("/").getPath()+"equipment.conf"));
            } catch (IOException e) {
                log.error(e.getMessage(), e);
            }
        }
    }

    public static EquipmentConfModel getEquipmentConfModel()
    {
        if (equipmentConfModel == null) {
            init();
            equipmentConfModel = new EquipmentConfModel();
            equipmentConfModel.setBucketCapacity(PROPS.getIntegerValue("bucket.capacity"));
            equipmentConfModel.setBucketCardNumbers(PROPS.getIntegerValue("bucket.card.number"));
        }
        return equipmentConfModel;
    }

}
